package fun.werfamily.wf.user.core.domain.enums;

import java.util.Arrays;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;

/**
 * @Author: Mr.WenMing Zhang
 * @Date: 2022/07/29 10:28
 * @Description:
 **/
public enum SmsTemplateEnum {
    RESET_PASSWORD("SMS_190267866","reset", "重置密码验证码模板"),
    VERIFY("SMS_275710131","verify", "验证码")
    ;
    private String templateCode;
    private String type;
    private String desc;

    static Map<String, SmsTemplateEnum> smsTemplateEnumMap;
    static Map<String, SmsTemplateEnum> smsTypeEnumMap;
    public String getTemplateCode() {
        return templateCode;
    }

    public void setTemplateCode(String templateCode) {
        this.templateCode = templateCode;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public String getDesc() {
        return desc;
    }

    public void setDesc(String desc) {
        this.desc = desc;
    }

    SmsTemplateEnum(String templateCode, String type, String desc) {
        this.templateCode = templateCode;
        this.type = type;
        this.desc = desc;
    }

    static {
        smsTemplateEnumMap = Arrays.stream(SmsTemplateEnum.values()).collect(Collectors.toMap(SmsTemplateEnum::getTemplateCode, Function.identity()));
        smsTypeEnumMap = Arrays.stream(SmsTemplateEnum.values()).collect(Collectors.toMap(SmsTemplateEnum::getType, Function.identity()));
    }

    public static SmsTemplateEnum getByTemplateCode(String templateCode){
        return SmsTemplateEnum.smsTemplateEnumMap.get(templateCode);
    }

    public static SmsTemplateEnum getByType(String type){
        return SmsTemplateEnum.smsTypeEnumMap.get(type);
    }
}
